﻿using System;
using System.Web.UI;
using ITViet.Web.App_Code;
using ITViet.Services;
using ITViet.Domains;

namespace ITViet.Web.MasterPages
{
	public partial class Default : MasterPage
	{
		#region Events
		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack && !Page.IsCallback)
			{
				LoadOverview();
				LoadSlider();
			}
		}

		protected void btnEN_Click(object sender, ImageClickEventArgs e)
		{
			((BasePage)Page).CurrentLanguage = GlobalCache.Instance.English;
			Response.Redirect(Request.RawUrl);
		}

		protected void btnVN_Click(object sender, ImageClickEventArgs e)
		{
			((BasePage)Page).CurrentLanguage = GlobalCache.Instance.Vietnamese;
			Response.Redirect(Request.RawUrl);
		}
		#endregion

		#region Methods
		private void LoadOverview()
		{
			TList<HtmlContent> htmlOverview = new HtmlContentService().GetByTypeAndLanguage((int)MenuTypeList.Overview, (Page as BasePage).CurrentLanguage.Id);
			if (htmlOverview.Count > 0)
			{
				ltOverview.Text = htmlOverview[0].Summary;
			}
		}

		private void LoadSlider()
		{
			rptSlider.DataSource = new MultimediaService().GetPhotoByType(MultimediaType.Intro);
			rptSlider.DataBind();
		}
		#endregion
	}
}
